<?php
/**
 * Created by PhpStorm.
 * User: liu85
 * Date: 2019/2/24
 * Time: 14:05
 */

namespace app\admin\controller;


use app\common\consts\ErrorConst;
use app\common\helper\UserHelper;
use think\facade\Request;

class Admin extends Auth
{
    public function editPassword()
    {
        return $this->fetch('edit_password');
    }


    public function doEditPassword(){
        if(!Request::isPost()){
            _failure(ErrorConst::BASE_ERR_MSG);
        }
        $pass = $this->request->param('pass');
        $repass = $this->request->param('repass');
        if($pass != $repass){
            _failure('两次密码不一致');
        }
        if($pass == ''){
            _success('操作成功');
        }
        $pass = UserHelper::makePassword($pass);
        $last = $this->admin->save(['pass'=>$pass]);
        self::doLast($last);
    }
}